home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999-2002 Macromedia, Inc. All rights reserved.
-
- //--------------- GLOBAL VARIABLES ---------------
- var OBJECT_FILE = dw.getConfigurationPath() + '/Objects/Common/Table.htm';
- var DEBUG_FILE = dw.getConfigurationPath() + '/Objects/Common/TABLE_DEBUG.txt';
- var helpDoc = MM.HELP_objTable;
- var gDialogShown = false;
-
- //--------------- API FUNCTIONS ---------------
-
- function isDOMRequired() {
- return false;
- }
-
-
-
- function objectTag() {
- var Columns = document.theForm.Cols.value;
- var Rows = document.theForm.Rows.value;
- var Border = document.theForm.Border.value;
- var Width = document.theForm.Width.value;
- var cellSpacing = document.theForm.Cellspace.value;
- var cellPadding = document.theForm.Cellpad.value;
- var unitChoice = document.forms[0].Units.selectedIndex;
- var retStr = "";
-
- var tableCells='<'+'TD>' + dw.getDocumentDOM("document").getNBSPChar() + '<'+'/TD>';
- var tableRow='',tableContent='';
- var openTag= '<' + 'table ', spaceIndex;
- var widthAttr;
-
- //change any negative or non-numeric row or column value into 1
- Columns = parseInt(Columns);
- Columns = (Columns>0)?Columns:1;
- Rows = parseInt(Rows);
- Rows = (Rows>0)?Rows:1;
-
- //CREATE TABLE
- //determine contents of 1 table row
- for (i=0; i< Columns; i++)
- tableRow+=tableCells;
- tableRow = "<"+"TR>" + tableRow + "<"+"/TR>";
-
- //determine number of table rows & concatanate rows together
- for (i=0; i< Rows; i++)
- tableContent += tableRow;
-
- //add percent or pixel values to opening tag, if applicable
- if (Width)
- openTag += 'width="'+Width + ((unitChoice == 0)? '%" ' : '" ');
- //add border value, if applicable
- if (Border)
- openTag+='border="' + Border + '" ';
- //add cellspacing value, if applicable
- if (cellSpacing)
- openTag+='cellspacing="' + cellSpacing + '" ';
- //add cellpadding value, if applicable
- if (cellPadding)
- openTag+='cellpadding="' + cellPadding + '" ';
-
- //strip extra space from openTag, if it exists
- spaceIndex = openTag.length-1
- if (escape(openTag.charAt(spaceIndex))=='%20')
- openTag = openTag.substring(0,spaceIndex);
-
- openTag += '>' + tableContent;
- openTag += '<'+'/table'+'>';
-
- retStr = openTag;
-
- if (gDialogShown){
- saveExtension(document);
- }
- gDialogShown = false; // Reset show dialog global.
-
- // if accessibility preference for tables is on, call command to generate
- // table string. pass already-set options as arguments; replace retStr with value
- // generated by command.
- if (dw.getPreferenceString("Accessibility", "Accessibility Table Options", "") == 'TRUE'){
-
- var cmdFile = dreamweaver.getConfigurationPath() + "/Commands/TableOptions.htm";
- var cmdDOM = dreamweaver.getDocumentDOM(cmdFile);
-
- dreamweaver.runCommand("TableOptions.htm",Columns,Rows,Border,Width,cellSpacing,cellPadding,unitChoice);
- var cmdRetStr = (cmdDOM.parentWindow.createTableStr());
- retStr = (cmdRetStr != "")?cmdRetStr:retStr;
-
- }
-
- return retStr;
- }
-
- //--------------- LOCAL FUNCTIONS ---------------
-
- function saveExtension(curDOM) {
- var curHTML = DWfile.read(curDOM.URL);
- var tempFilename = dw.getConfigurationPath() + '/Shared/MM/Cache/empty.htm';
- if (DWfile.exists(tempFilename)) {
- var tempDOM = dw.getDocumentDOM(tempFilename);
- tempDOM.documentElement.outerHTML = curHTML;
- var atrStr = DWfile.getAttributes(curDOM.URL);
- if (tempDOM.body.outerHTML != curDOM.body.outerHTML && (atrStr.indexOf('R') == -1)){
- tempDOM.body.outerHTML = curDOM.body.outerHTML;
- DWfile.write(curDOM.URL, tempDOM.documentElement.outerHTML);
- }
- }
- }
-
- function initializeUI()
- {
- document.theForm.Rows.focus(); //set focus on textbox
- document.theForm.Rows.select(); //set insertion point into textbox
- gDialogShown = true;
- }
-